package com.imooc.mymall.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMethodMappingNamingStrategy;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * <h1>Swagger2配置类</h1>
 * @Author: crowsjian
 * @Date: 2020/7/19 9:16
 */
@Configuration
@EnableSwagger2
public class Swagger2Config {

    /**
     * <h2>Swagger2信息</h2>
     * @return
     */
    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                // API基本信息
                .apiInfo(apiInfo())
                // 设置允许暴露的接口
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.imooc.mymall.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    /**
     * <h2>API基本信息</h2>
     * @return
     */
    public ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("阿健的项目")
                .description("好好学习，天天向上")
                .contact(new Contact("阿健","",""))
                .version("1.0.0")
                .build();
    }
}
